package com.ibeeking.gmc.global.g.rest.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.*;
import redis.clients.jedis.util.Pool;

/**
 * @Author ibeeking
 * Data : 17:28
 */
@Configuration
public class JedisConfig {

    @Value("${spring.redis.host:127.0.0.1}")
    private String host;

    @Value("${spring.redis.port:3306}")
    private Integer port;

    @Value("${spring.redis.password:123456}")
    private String password;

    @Value("${spring.redis.database:0}")
    private int database;

    @Bean
    public Jedis shardedJedisPool() {
        Jedis jedis = new Jedis(host, port);
        jedis.auth(password);
        return jedis;
    }
    @Bean
    public Pool<Jedis> getPool() {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        Pool pool = new JedisPool(jedisPoolConfig, host, port, 5000, password);
        return pool;
    }
}
